<template>
  <div id="app">
    <!-- 路由占位-->
      <router-view></router-view>
  </div>
</template>

<script>
//import Login from "./components/Login";
export default {
  name:"App",
  mounted(){
    //后台获取数据
    //这里的数据应添加up主对应的nickName,方便前端渲染
    this.$http.get('/api/selectVideo').then(res=>{
      console.log(res)
      let videos = res.data.data.data
      //将数据存至vuex
      this.$store.dispatch('setVideos',videos)
      sessionStorage.setItem('videos',JSON.stringify(videos))
    }).catch(error=>{
      this.$Message.error('获取后台数据失败')
    })
    // 在页面刷新时将vuex里的信息保存到sessionStorage里
    // beforeunload事件在页面刷新时先触发
    /*
    window.addEventListener('beforeunload', () => {
      sessionStorage.setItem('store', JSON.stringify(this.$store.state))
    })
     */
  }
}
/**
export default {
  name: 'App',
  components:{Login},
  data(){
    return{
      show:true
    }
  },
  mounted(){
    // console.log('App_mounted')
    const token = window.sessionStorage.getItem('token')
    if(token){
      // console.log('token:',token)
      this.show = false
      this.$router.push({
        path:'/bingo'
      })
    }else{
      console.log('token失效')
      // console.log('token:',token)
    }

  }

}
  **/
</script>

<style>


</style>
